<?php
class View{
	
	private $smarty;
	
	public function __construct(){
		$webroot = $_SERVER['DOCUMENT_ROOT'];
		include_once $webroot.'/includes/Smarty/Smarty.class.php';
		$smarty = new Smarty();
		$this->smarty = $smarty;
		$smarty->caching = FALSE;//开启缓存
		$smarty->template_dir = $webroot.'/application/views/';
		$smarty->compile_dir = $webroot.'/caches/smarty/templates_c';
		$smarty->cache_dir = $webroot.'/caches/smarty/caches';
		$smarty->left_delimiter = "<{";
		$smarty->right_delimiter = "}>";
	}
	
	public function display($content,$templement){
		$local  = "http://".$_SERVER['HTTP_HOST'];
		$commons = "http://".$_SERVER['HTTP_HOST']."/application/views/commons";
		$smarty = $this->smarty;
		foreach ($content as $key=>$value){
			$smarty->assign($key,$value);
		}
		$smarty->assign("commons",$commons);
		$smarty->assign("local",$local);
		$smarty->display($templement);
	}
	
	
}

	